<template>
	<el-container>
		<el-header>欢迎您,{{userInfo.accountName}} <span
				style="position: relative;left: 500px;height: 150px;">XXXX缺陷跟踪管理系统</span>
			<div style="float: right;">
				<!-- <router-link to="/changepwd">修改密码</router-link>-->
				<el-link type="primary" @click="logout" style="color:gray;font-size: large;">退出登录</el-link>
			</div>
		</el-header>
		<el-container>
			<el-aside width="200px">
				<el-menu >
					<menusComponent :menusData="menus"></menusComponent>
				</el-menu>
			</el-aside>
			<el-main>
				<router-view></router-view>
			</el-main>
		</el-container>
	</el-container>
</template>

<script>
	import menusComponent from './Menu.vue'
	export default {
		name: "mainpage",
		components: {
			menusComponent
		},
		data() {
			return {
				userInfo: {
					accountid: 0,
					accountName: ""
				},
				menus: []
			}
		},
		methods: {
			getUser() {
				var user = localStorage.getItem("loginUser")
				this.userInfo = JSON.parse(user)
			},
			findMenus() {
				this.$http.get("/menus/getMenusByAccountId", {
					params: {
						"accountId": this.userInfo.accountId
					}
				}).then(resp => {
					// console.log(resp.data.data)
					this.menus = resp.data.data
				})
			},
			logout() {
				localStorage.removeItem("loginUser")
				this.$message({
					message: "退出登陆成功",
					type: 'success',
					duration: 1000
				})
				this.$router.push("/")
			},
		},
		created() {
			this.getUser()
			this.findMenus()
		}
	}
</script>

<style>
</style>
